package com.i2863.watchdog.wangsu;

/**
 * @author xuweiwei
 * @date 2019/4/23
 */
public enum ErrorReturnCode {

    USER_EMPTY(1001, "不能为空"),
    USER_ILLEGAL(1002, "用户不合法"),
    SIGN_NOT_PASS(1003, "签名验证不通过"),
    ILLEGAL_PHONE(1004, "无效号码"),
    CONTENT_EMPTY(1005, "内容为空"),
    CONtENT_OUT_OF_LENGTH(1006, "内容超过最大长度"),
    MONEY_ENOUGH(1007, "余额不足"),
    EMPTY_PHONE(1008, "空号关机停机"),
    PHONENUM_IN_BLACK(1009, "黑名单"),
    SENSITIVES_WORDS(1010, "检测到敏感词"),
    FREQUENCY_OVERRUN(1011, "频次超限"),
    GATEWAY_SHIELD(1012, "地区网关屏蔽"),
    SYSTEM_ERROR(1013, "运营商内部系统错误");

    /**
     * 错误编码
     */
    private int code;
    /**
     * 错误说明
     */
    private String msg;


    ErrorReturnCode(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static ErrorReturnCode valueOf(int code) {
        for (ErrorReturnCode type : ErrorReturnCode.values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("无效的code:" + code);
    }

}
